﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace JewererBasic.BO
{
    public class ProcessBO
    {                
        public static List<PROCESS> PROCESSes()
        {
            MSQDBEntities db = new MSQDBEntities();
            return db.PROCESSes.ToList();
        }

        public static int GetId(string name)
        {
            MSQDBEntities db = new MSQDBEntities();
            var query = (from d in db.PROCESSes
                         where d.Name.Equals(name)
                         select d).ToList();
            if (query.Count > 0)
                return query.First().Id;
            throw new NullReferenceException("Can't find process name: " + name);                 
        }

        // Check if it is allowed to export stone for bag in process
        public static bool IsAllowedStoneExport(int process_id)
        {
            MSQDBEntities db = new MSQDBEntities();
            PROCESS process = db.PROCESSes.Find(process_id);
            if (process != null)
            {
                if (process.Name.Equals("Stone Service"))
                    return true;
            }
            return false;
        }
    }
}